<template>
  <div class="container">
    <el-form ref="form">
      <el-form-item label="商品名">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="类型">
        <el-input v-model="form.type"></el-input>
      </el-form-item>
      <el-form-item label="单价">
        <el-input v-model="form.price"></el-input>
      </el-form-item>
      <el-form-item
        label="重量
       "
      >
        <el-input v-model="form.weight"></el-input>
      </el-form-item>
      <el-form-item label="生产日期">
        <el-input v-model="form.date"></el-input>
      </el-form-item>
      <el-form-item label="保质期">
        <el-input v-model="form.livedate"></el-input>
      </el-form-item>
      <el-form-item label="介绍">
        <el-input v-model="form.describe"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="updatehandel">修改</el-button>
        <el-button @click="cancleHandel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      id: "",
      form: {
        name: "",
        phone: "",
        time: "",
        address: "",
        describe: "",
        isService: "",
      },
    };
  },
  mounted() {
    this.id = this.$route.params.id;
    this.form = this.$route.query.scope;
  },
  methods: {
    updatehandel() {
      this.$store.dispatch("commoditys/updatecommoditysAction", this.form);
       this.$router.push({ name:'Commodity'})
    },
    cancleHandel() {
      this.form.name = "";
      this.form.phone = "";
      this.form.time = "";
      this.form.address = "";
      this.form.describe = "";
    },
  },
};
</script>

<style scoped>
.container {
  margin: 25px auto;
  width: 800px;
}
</style>